using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using System.Collections.Generic;

namespace EventAbstractionAPI.RuleEngine
{
	public sealed partial class BaseParserWorkflow: SequentialWorkflowActivity
	{
		public BaseParserWorkflow()
		{
			InitializeComponent();
		}

        private List<ICapturedEvent> value3;
        public List<ICapturedEvent> Value3
        {
            get { return value3; }
            set { value3 = value; }
        }
        private IEnumerator enumerator;
        public IEnumerator Enumerator
        {
            get { return enumerator; }
            set { enumerator = value; }
        }

        private int index = -1;
        public int Index
        {
            get { return index; }
            set { index = value; }
        }

        private Object currentInstance;
        public Object CurrentInstance
        {
            get { return currentInstance; }
            set { currentInstance = value; }
        }

        public String CurrentCapturedEvent
        {
            get
            {
                return ((ICapturedEvent)enumerator.Current).EventName + ((ICapturedEvent)enumerator.Current).ComplexName;
            }
        }

        public String LookAhead(int theIndex)
        {
            String s = "";

            if (theIndex >= value3.Count)
            {
                return String.Empty;
            }
            try
            {
                s = value3[theIndex].EventName + value3[theIndex].ComplexName;
            }
            catch (Exception)
            {
            }

            return s;
        }

        public Boolean NotAtEnd(int theIndex, int lookahead)
        {
            return (this.index + lookahead < this.value3.Count);
        }

        public Boolean hasNext()
        {
            IEnumerator tempEnumerator = this.enumerator;
            return tempEnumerator.MoveNext();
        }

        public void InsertComplexEvent(int theIndex,int range, String name)
        {
            CapturedEvent complexEvent = new CapturedEvent(name);
            complexEvent.EventTimeStamp = DateTime.Now;
            List<ICapturedEvent> transformList = this.value3.GetRange(theIndex, range);

            for(int i = 0; i <transformList.Count; i++ )
            {
                complexEvent.EventArgumentsList.AddRange(transformList[i].EventArgumentsList);
            }
            
            this.value3.RemoveRange(theIndex, range);
            this.value3.Insert(theIndex, complexEvent);
        }
	}

}
